package com.example.srb.core.controller.api;


import com.example.srb.common.result.Result;
import com.example.srb.core.pojo.entity.LendItemReturn;
import com.example.srb.core.service.LendItemReturnService;
import com.example.srb.service2base.util.JwtUtils;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * <p>
 * 标的出借回款记录表 前端控制器
 * </p>
 *
 * @author Helen
 * @since 2021-02-20
 */
@RestController
@RequestMapping("/api/core/lendItemReturn")
public class LendItemReturnController {

    @Resource
    private LendItemReturnService lendItemReturnService;

    @ApiOperation("获取回款计划列表")
    @GetMapping("/auth/list/{lendId}")
    public Result list(HttpServletRequest request,
                       @ApiParam(value = "标的id",required = true)@PathVariable Long lendId){
        String token = request.getHeader("token");
        Long userId = JwtUtils.getUserId(token);
        List<LendItemReturn> lendItemReturnList = lendItemReturnService.selectByLendId(lendId,userId);
        return Result.ok().data("list",lendItemReturnList);
    }
}

